﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using Monkey.Warrenty.Biz;

namespace MonkeyWarranty.Web.WarrantyTickets
{
    public partial class LendProducts : System.Web.UI.Page
    {
        #region Properties

        private static WarrantyProductBiz _warrantyProductBiz;

        private static WarrantyProductBiz WarrantyProductManager
        {
            get { return _warrantyProductBiz ?? (_warrantyProductBiz = new WarrantyProductBiz()); }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [WebMethod(EnableSession = true)]
        public static object TicketProductList(int jtStartIndex, int jtPageSize, string jtSorting)
        {
            var ticketCount = WarrantyProductManager.GetLendProductsCount();
            var products = WarrantyProductManager.GetLendProducts(jtStartIndex, jtPageSize, jtSorting);
            return new { Result = "OK", Records = products, TotalRecordCount = ticketCount };
        }

        [WebMethod(EnableSession = true)]
        public static object ReceivedBack(List<long> productIds)
        {
            WarrantyProductManager.ReceivedBack(productIds);
            return new { Result = "OK" };
        }
    }
}